package com.atguigu.tingshu.order.enumeration;

import com.atguigu.tingshu.common.constant.SystemConstant;

public enum PayWayEnum {

    PAY_WAY_WEIXIN(SystemConstant.ORDER_PAY_WAY_WEIXIN, "微信"),
    PAY_WAY_ALIPAY(SystemConstant.ORDER_PAY_WAY_ALIPAY, "支付宝"),
    PAY_WAY_ACCOUNT(SystemConstant.ORDER_PAY_ACCOUNT, "余额") ;

    private String code ;
    private String name ;

    private PayWayEnum(String code , String name) {
        this.code = code ;
        this.name = name ;
    }

    public static String getPayWayName(String code) {
        PayWayEnum[] payWayEnums = PayWayEnum.values();     // 获取所有的枚举项
        for(PayWayEnum payWayEnum : payWayEnums) {
            if(payWayEnum.code.equals(code)) {
                return payWayEnum.name ;
            }
        }
        return null ;
    }

}
